package com.lagou.controller;

import com.lagou.entity.Course;
import com.lagou.entity.CourseDTO;
import com.lagou.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 */
@RestController
@RequestMapping("course")
@CrossOrigin //跨域
public class CourseController {

    @Autowired
    private CourseService courseService;

    @GetMapping("getAllCourse")
    public List<CourseDTO> getAllCourse() {
        List<CourseDTO> list = courseService.getAllCourse();
        return list;
    }

    @GetMapping("getCoursesByUserId")
    public List<CourseDTO> getCoursesByUserId( Integer userid) {
        System.out.println("userid = " + userid);
        return courseService.getCoursesByUserId(userid);
    }

    @GetMapping("getCourseById/{courseid}")
    public CourseDTO getCourseById(@PathVariable("courseid")Integer courseid) {
        CourseDTO courseDTO = courseService.getCourseById(courseid);
        return courseDTO;
    }



}